@import "tailwindcss";
@import "tw-animate-css";

@custom-variant dark (&:is(.dark *));

@theme {
  --font-sans: "Inter", ui-sans-serif, system-ui, sans-serif,
    "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
}

html,
body {
  /* Background now derives strictly from theme tokens via body classes */
}

@theme inline {
  --radius-sm: calc(var(--radius) - 4px);
  --radius-md: calc(var(--radius) - 2px);
  --radius-lg: var(--radius);
  --radius-xl: calc(var(--radius) + 4px);
  --color-background: rgb(var(--background));
  --color-foreground: rgb(var(--foreground));
  --color-card: rgb(var(--card));
  --color-card-foreground: rgb(var(--card-foreground));
  --color-popover: rgb(var(--popover));
  --color-popover-foreground: rgb(var(--popover-foreground));
  --color-primary: rgb(var(--primary));
  --color-primary-foreground: rgb(var(--primary-foreground));
  --color-secondary: rgb(var(--secondary));
  --color-secondary-foreground: rgb(var(--secondary-foreground));
  --color-muted: rgb(var(--muted));
  --color-muted-foreground: rgb(var(--muted-foreground));
  --color-accent: rgb(var(--accent));
  --color-accent-foreground: rgb(var(--accent-foreground));
  --color-destructive: rgb(var(--destructive));
  --color-destructive-foreground: rgb(var(--destructive-foreground));
  --color-border: rgb(var(--border));
  --color-input: rgb(var(--input));
  --color-ring: rgb(var(--ring));
  --color-chart-1: rgb(var(--chart-1));
  --color-chart-2: rgb(var(--chart-2));
  --color-chart-3: rgb(var(--chart-3));
  --color-chart-4: rgb(var(--chart-4));
  --color-chart-5: rgb(var(--chart-5));

  /* Video editor specific colors */
  --color-panel-background: rgb(var(--panel-background));
  --color-panel-border: rgb(var(--panel-border));
  --color-panel-header: rgb(var(--panel-header));
  --color-timeline-background: rgb(var(--timeline-background));
  --color-timeline-track: rgb(var(--timeline-track));
  --color-timeline-ruler: rgb(var(--timeline-ruler));
  --color-scrubber: rgb(var(--scrubber));
  --color-playhead: rgb(var(--playhead));
}

:root {
  --radius: 0.375rem;

  /* Light theme - Clean monochrome with blue accent */
  --background: 255 255 255;
  --foreground: 15 23 42;
  --card: 255 255 255;
  --card-foreground: 15 23 42;
  --popover: 255 255 255;
  --popover-foreground: 15 23 42;
  --primary: 37 99 235; /* Clean blue accent */
  --primary-foreground: 255 255 255;
  --secondary: 248 250 252;
  --secondary-foreground: 51 65 85;
  --muted: 241 245 249;
  --muted-foreground: 100 116 139;
  --accent: 241 245 249;
  --accent-foreground: 51 65 85;
  --destructive: 220 38 38;
  --destructive-foreground: 255 255 255;
  --border: 226 232 240;
  --input: 226 232 240;
  --ring: 37 99 235;
  --chart-1: 37 99 235;
  --chart-2: 34 197 94;
  --chart-3: 168 85 247;
  --chart-4: 251 146 60;
  --chart-5: 220 38 38;

  /* Panel colors */
  --panel-background: 248 250 252;
  --panel-border: 226 232 240;
  --panel-header: 241 245 249;

  /* Video editor specific */
  --timeline-background: 248 250 252;
  --timeline-track: 255 255 255;
  --timeline-ruler: 241 245 249;
  --scrubber: 37 99 235;
  --playhead: 220 38 38;
}

.dark {
  --background: 9 9 11;
  --foreground: 255 255 255;
  --card: 18 18 20;
  --card-foreground: 255 255 255;
  --popover: 18 18 20;
  --popover-foreground: 255 255 255;
  --primary: 198 255 0; /* Neon yellow-green accent for dark mode */
  --primary-foreground: 9 9 11;
  --secondary: 39 39 42;
  --secondary-foreground: 255 255 255;
  --muted: 39 39 42;
  --muted-foreground: 161 161 170;
  --accent: 39 39 42;
  --accent-foreground: 255 255 255;
  --destructive: 239 68 68;
  --destructive-foreground: 255 255 255;
  --border: 39 39 42;
  --input: 39 39 42;
  --ring: 198 255 0;
  --chart-1: 198 255 0;
  --chart-2: 59 130 246;
  --chart-3: 168 85 247;
  --chart-4: 251 146 60;
  --chart-5: 239 68 68;

  /* Panel colors for dark mode */
  --panel-background: 18 18 20;
  --panel-border: 39 39 42;
  --panel-header: 39 39 42;

  /* Video editor specific for dark mode */
  --timeline-background: 9 9 11;
  --timeline-track: 18 18 20;
  --timeline-ruler: 39 39 42;
  --scrubber: 198 255 0;
  --playhead: 239 68 68;
}

@layer base {
  * {
    border-color: rgb(var(--border));
    outline-color: rgb(var(--ring) / 0.5);
  }
  body {
    background-color: rgb(var(--background));
    color: rgb(var(--foreground));
  }

  /* Theme-aware scrollbars */
  ::-webkit-scrollbar {
    width: 12px;
    height: 12px;
  }

  ::-webkit-scrollbar-track {
    background: rgb(var(--muted));
    border-radius: 6px;
  }

  ::-webkit-scrollbar-thumb {
    background: rgb(var(--muted-foreground) / 0.5);
    border-radius: 6px;
    border: 2px solid rgb(var(--muted));
  }

  ::-webkit-scrollbar-thumb:hover {
    background: rgb(var(--muted-foreground) / 0.7);
  }

  ::-webkit-scrollbar-thumb:active {
    background: rgb(var(--muted-foreground) / 0.8);
  }

  ::-webkit-scrollbar-corner {
    background: rgb(var(--muted));
  }

  /* Thinner scrollbars for timeline and panels */
  .timeline-scrollbar::-webkit-scrollbar,
  .panel-scrollbar::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }

  .timeline-scrollbar::-webkit-scrollbar-thumb,
  .panel-scrollbar::-webkit-scrollbar-thumb {
    border: 1px solid rgb(var(--muted));
  }

  /* Firefox */
  * {
    scrollbar-width: thin;
    scrollbar-color: rgb(var(--muted-foreground) / 0.5) rgb(var(--muted));
  }

  /* Chat specific styles - ensure proper text wrapping */
  .chat-message-content {
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    hyphens: auto;
    white-space: pre-wrap;
    max-width: 100%;
  }

  /* Prevent horizontal overflow in chat areas */
  .chat-container * {
    max-width: 100%;
    overflow-x: hidden;
  }

  /* Ensure textarea never exceeds container width */
  .chat-input-area textarea {
    max-width: 100%;
    box-sizing: border-box;
  }
}

/* Custom animations for 404 page */
@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fade-in-up {
  from {
    opacity: 0;
    transform: translateY(40px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0px) rotate(0deg);
  }
  50% {
    transform: translateY(-20px) rotate(180deg);
  }
}

@keyframes float-delayed {
  0%,
  100% {
    transform: translateY(0px) rotate(0deg);
  }
  50% {
    transform: translateY(-30px) rotate(-180deg);
  }
}

@keyframes float-slow {
  0%,
  100% {
    transform: translateY(0px) rotate(0deg);
  }
  50% {
    transform: translateY(-15px) rotate(90deg);
  }
}

@keyframes float-reverse {
  0%,
  100% {
    transform: translateY(-10px) rotate(0deg);
  }
  50% {
    transform: translateY(10px) rotate(180deg);
  }
}

@keyframes float-gentle {
  0%,
  100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-8px);
  }
}

@keyframes twinkle {
  0%,
  100% {
    opacity: 0.3;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.2);
  }
}

@keyframes pulse-slow {
  0%,
  100% {
    opacity: 0.8;
  }
  50% {
    opacity: 0.3;
  }
}

@keyframes spin-slow {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Enhanced animations for polished 404 page */
@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

@keyframes glow-pulse {
  0%,
  100% {
    box-shadow: 0 0 20px rgba(37, 99, 235, 0.1),
      0 0 40px rgba(37, 99, 235, 0.05);
  }
  50% {
    box-shadow: 0 0 30px rgba(37, 99, 235, 0.2), 0 0 60px rgba(37, 99, 235, 0.1);
  }
}

@keyframes float-icon {
  0%,
  100% {
    transform: translateY(0px) rotate(0deg);
  }
  25% {
    transform: translateY(-8px) rotate(2deg);
  }
  50% {
    transform: translateY(-4px) rotate(0deg);
  }
  75% {
    transform: translateY(-12px) rotate(-2deg);
  }
}

@keyframes gradient-shift {
  0%,
  100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

@keyframes border-glow {
  0%,
  100% {
    border-color: rgba(37, 99, 235, 0.2);
    box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.1);
  }
  50% {
    border-color: rgba(37, 99, 235, 0.4);
    box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.2);
  }
}

.animate-fade-in {
  animation: fade-in 0.8s ease-out;
}

.animate-fade-in-up {
  animation: fade-in-up 1s ease-out;
}

.animate-float {
  animation: float 6s ease-in-out infinite;
}

.animate-float-delayed {
  animation: float-delayed 8s ease-in-out infinite;
  animation-delay: 2s;
}

.animate-float-slow {
  animation: float-slow 10s ease-in-out infinite;
  animation-delay: 1s;
}

.animate-float-reverse {
  animation: float-reverse 7s ease-in-out infinite;
  animation-delay: 3s;
}

.animate-float-gentle {
  animation: float-gentle 4s ease-in-out infinite;
}

.animate-twinkle {
  animation: twinkle 2s ease-in-out infinite;
}

.animate-pulse-slow {
  animation: pulse-slow 3s ease-in-out infinite;
}

.animate-spin-slow {
  animation: spin-slow 3s linear infinite;
}

.animate-shimmer {
  animation: shimmer 3s ease-in-out infinite;
}

.animate-glow-pulse {
  animation: glow-pulse 4s ease-in-out infinite;
}

.animate-float-icon {
  animation: float-icon 6s ease-in-out infinite;
}

.animate-gradient-shift {
  animation: gradient-shift 8s ease-in-out infinite;
  background-size: 200% 200%;
}

.animate-border-glow {
  animation: border-glow 3s ease-in-out infinite;
}

/* Glass morphism effects */
.glass-morphism {
  backdrop-filter: blur(16px) saturate(180%);
  background-color: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.125);
}

.glass-morphism-dark {
  backdrop-filter: blur(16px) saturate(180%);
  background-color: rgba(17, 25, 40, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.125);
}

/* Enhanced shadow utilities */
.shadow-3xl {
  box-shadow: 0 35px 60px -12px rgba(0, 0, 0, 0.25);
}

.shadow-glow {
  box-shadow: 0 0 20px rgba(37, 99, 235, 0.15);
}

.shadow-glow-lg {
  box-shadow: 0 0 40px rgba(37, 99, 235, 0.2);
}

/* Indeterminate top loader */
.indeterminate-line {
  position: relative;
  height: 2px;
  width: 100%;
  overflow: hidden;
  background: transparent;
}
.indeterminate-line::before {
  content: "";
  position: absolute;
  left: -40%;
  top: 0;
  height: 100%;
  width: 40%;
  background: currentColor;
  border-radius: 2px;
  animation: indeterminate-slide 1.2s ease-in-out infinite;
}

@keyframes indeterminate-slide {
  0% { left: -40%; width: 40%; }
  50% { left: 20%; width: 60%; }
  100% { left: 100%; width: 40%; }
}